package com.briup.recognition.service.impl;

import com.briup.recognition.bean.Application;
import com.briup.recognition.bean.ApplicationExample;
import com.briup.recognition.dao.ApplicationMapper;
import com.briup.recognition.service.IApplicationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class ApplicationServiceImpl implements IApplicationService {
    @Resource
    private ApplicationMapper applicationMapper;
    @Override
    public List<Application> query() {
        ApplicationExample example = new ApplicationExample();
        //条件
        return applicationMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(Application application) {
        if(application.getId()!=null){
            applicationMapper.updateByPrimaryKey(application);
        } else {

            application.setCreateTime(new Date().getTime());
            applicationMapper.insert(application);
        }

    }

    @Override
    public void deleteById(long id) {applicationMapper.deleteByPrimaryKey(id);
    }
}
